import request from '@/utils/request'
import type {
  SkuResponseData,
  SkuResponsePageData,
  SkuResponseInfoData,
} from './type'

enum API {
  //根据spuId获取sku信息
  GetSkuInfoBySpuID_URL = '/admin/product/findBySpuId/',
  //获取sku分页数据
  GetSkuPageData_URL = '/admin/product/list/',
  //下架操作
  CancelSale_URL = '/admin/product/cancelSale/',
  //上架操作
  OnSale_URL = '/admin/product/onSale/',
  //根据skuID获取sku信息
  GetSkuInfoBySkuID_URL = '/admin/product/getSkuInfo/',
  //根据skuID删除sku信息
  DeleteSkuByID_URL = '/admin/product/deleteSku/',
}

//根据SpuID获取Sku信息
export const GetSkuInfoBySpuID = (spuId: number) =>
  request.get<any, SkuResponseData>(API.GetSkuInfoBySpuID_URL + spuId)
//获取sku分页数据
export const GetSkuPageData = (currentPage: number, total: number) =>
  request.get<any, SkuResponsePageData>(
    API.GetSkuPageData_URL + currentPage + '/' + total,
  )
//sku下架处理
export const CancelSale = (id: number) =>
  request.get<any, any>(API.CancelSale_URL + id)
//sku上架处理
export const OnSale = (id: number) => request.get<any, any>(API.OnSale_URL + id)

//根据SkuID获取Sku信息
export const GetSkuInfoBySkuID = (skuId: number) =>
  request.get<any, SkuResponseInfoData>(API.GetSkuInfoBySkuID_URL + skuId)
//根据SkuID删除Sku信息
export const DeleteSkuByID = (skuId: number) =>
  request.delete<any, any>(API.DeleteSkuByID_URL + skuId)
